home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / winspect.zip / WSPTEXEM.C < prev    next >
C/C++ Source or Header  |  1993-10-18  |  6KB  |  191 lines

  1. /****************************************************************************
  2.  *                                                                          *
  3.  *  Projeto:  Windows Inspector Programa Exemplo                            *
  4.  *                                                                          *
  5.  *  Modulo :  WsptExem.C                                                    *
  6.  *                                                                          *
  7.  *  Autor  :  Noriel Chang Reissig                                          *
  8.  *                                                                          *
  9.  *  Criacao: 15/04/93                                                       *
  10.  *  Revisao: 23/05/93                                                       *
  11.  *  Modific: 23/05/93                                                       *
  12.  *                                                                          *
  13.  ****************************************************************************
  14.  
  15.  Obs.:
  16.       Este programa demonstra a utilizacao da biblioteca de funcoes INSPECTx.LIB,
  17.       bem como a utilizacao da ferramenta de debug Winspector.
  18.  
  19. */
  20.  
  21. #include  <windows.h>
  22.  
  23. #include  "Winspect.h"
  24.  
  25.  
  26.  
  27. long FAR PASCAL WindowProc( HWND, WORD, WORD, LONG);
  28. char szAppName[]="Using Winspector";
  29.  
  30. #pragma argsused
  31. int PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdParam, int nCmdShow)
  32. {
  33.     HWND        hwnd;
  34.     MSG         msg;
  35.     WNDCLASS    wndclass;
  36.  
  37.  
  38.     if (!hPrevInstance)
  39.     {
  40.        wndclass.style         = CS_HREDRAW | CS_VREDRAW;
  41.        wndclass.lpfnWndProc   = WindowProc;
  42.        wndclass.cbClsExtra    = 0;
  43.        wndclass.cbWndExtra    = 0;
  44.        wndclass.hInstance     = hInstance;
  45.        wndclass.hIcon         = LoadIcon( NULL, IDI_APPLICATION);
  46.        wndclass.hCursor       = LoadCursor( NULL, IDC_ARROW);
  47.        wndclass.hbrBackground = GetStockObject( WHITE_BRUSH);
  48.        wndclass.lpszMenuName  = NULL;
  49.        wndclass.lpszClassName = szAppName;
  50.  
  51.        RegisterClass( &wndclass);
  52.     }
  53.  
  54.     hwnd = CreateWindow( szAppName,                     // Window class name
  55.                          "Using Winspector v1.0",       // Window caption
  56.                          WS_OVERLAPPEDWINDOW,           // Window style
  57.                          CW_USEDEFAULT,                 // Initial x position
  58.                          CW_USEDEFAULT,                 // Initial y position
  59.                          CW_USEDEFAULT,                 // Initial x size
  60.                          CW_USEDEFAULT,                 // Initial y size
  61.                          NULL,                          // Parent window handle
  62.                          NULL,                          // Window menu handle
  63.                          hInstance,                     // Program instance handle
  64.                          NULL);                         // Creation parameters
  65.  
  66.     ShowWindow( hwnd, nCmdShow);
  67.     UpdateWindow( hwnd);
  68.  
  69.     StartWinspector();              // Chama Winspector
  70.     WinspectorAutoSave( TRUE);      // Liga o autosave
  71.  
  72.     while( GetMessage( &msg, NULL, 0, 0))
  73.     {
  74.        TranslateMessage( &msg);
  75.        DispatchMessage( &msg);
  76.     }
  77.  
  78.     CloseWinspector();              // Fecha o Winspector
  79.  
  80.     return( msg.wParam);
  81. }
  82.  
  83.  
  84.  
  85.  
  86.  
  87. long FAR PASCAL WindowProc( HWND hwnd, WORD message, WORD wParam, LONG lParam)
  88. {
  89.     char    szBuffer[256] = "While pressing keys look at the Winspector's window";
  90.     HDC         hdc;
  91.     PAINTSTRUCT  ps;
  92.     RECT         rect;
  93.     static BOOL  liga = TRUE;
  94.  
  95.     switch( message)
  96.     {
  97.        case WM_PAINT:
  98.  
  99.             hdc = BeginPaint( hwnd, &ps);
  100.  
  101.             GetClientRect( hwnd, &rect);
  102.  
  103.             DrawText( hdc, szBuffer, -1, &rect,
  104.                       DT_SINGLELINE | DT_CENTER | DT_VCENTER);
  105.  
  106.             EndPaint( hwnd, &ps);
  107.  
  108.             TellWinspector( "Wsptexem: WM_PAINT received");
  109.             return( 0);
  110.  
  111.        case WM_RBUTTONDOWN:
  112.             liga = !liga;
  113.             WinspectorAutoSave( liga);
  114.             break;
  115.  
  116.        case WM_SETFOCUS:
  117.             TellWinspector( "Wsptexem: received system FOCUS");
  118.             break;
  119.  
  120.        case WM_KILLFOCUS:
  121.             TellWinspector( "Wsptexem: loosing system FOCUS");
  122.             break;
  123.  
  124.        case WM_SIZE:
  125.             TellWinspector(    " wParam = Type           lParam = Height-Width");
  126.             TellWinspectorFmt( "WM_SIZE: wParam = %04Xh  lParam = %04d-%04d", wParam,
  127.                                            HIWORD( lParam), LOWORD( lParam));
  128.             break;
  129.  
  130.        case WM_KEYDOWN:
  131.             switch( wParam)
  132.             {
  133.                case VK_HOME:
  134.                     TellWinspector( "WsptExem:  HOME key");
  135.                     break;
  136.  
  137.                case VK_END:
  138.                     {
  139.                        char *szStr = "Tecla END";
  140.  
  141.                        TellWinspectorFmt( "WsptExem:  %s", szStr);
  142.                        break;
  143.                     }
  144.  
  145.                case VK_PRIOR:
  146.                     TellWinspector( "WsptExem:  PAGE UP key");
  147.                     break;
  148.  
  149.                case VK_NEXT:
  150.                     TellWinspector( "WsptExem:  PAGE DOWN key");
  151.                     break;
  152.  
  153.                case VK_UP:
  154.                     TellWinspector( "WsptExem:  UP key");
  155.                     break;
  156.  
  157.                case VK_DOWN:
  158.                     TellWinspector( "WsptExem:  DOWN key");
  159.                     break;
  160.  
  161.                case VK_LEFT:
  162.                     TellWinspector( "WsptExem:  LEFT key");
  163.                     break;
  164.  
  165.                case VK_RIGHT:
  166.                     TellWinspector( "WsptExem:  RIGHT key");
  167.                     break;
  168.  
  169.                case VK_INSERT:
  170.                     TellWinspector( "WsptExem:  INSERT key");
  171.                     break;
  172.  
  173.                case VK_DELETE:
  174.                     TellWinspector( "WsptExem:  DELETE key");
  175.                     break;
  176.  
  177.                default:
  178.                     TellWinspector( "Normal key pressed");
  179.                     break;
  180.             }
  181.             return(0);
  182.  
  183.        case WM_DESTROY:
  184.             PostQuitMessage( 0);
  185.             return( 0);
  186.     }
  187.  
  188.  
  189.     return( DefWindowProc( hwnd, message, wParam, lParam));
  190. }
  191.